import sys
from PyQt5.QtWidgets import QApplication, QWidget, QDesktopWidget

class MyWindow(QWidget):

    def __init__(this):
        super().__init__()
        this.resize(300, 200)
        this.moveToCenter()

    def moveToCenter(self):
        qr = self.frameGeometry()
        cp = QDesktopWidget().availableGeometry().center()
        qr.moveCenter(cp)
        self.move(qr.topLeft())


if __name__ == '__main__':
    app = QApplication(sys.argv)

    w = MyWindow()
    w.show()

    sys.exit(app.exec_())
